package com.fh.controller.app.voice;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fh.controller.base.BaseController;
import com.fh.entity.Page;
import com.fh.service.sk.banner.BannerService;
import com.fh.service.sk.production.ProductionService;
import com.fh.util.AppUtil;
import com.fh.util.PageData;

/**
 * app-产品详情-接口类  手机app接口实例
 *    
 * 相关参数协议：
 * 00	操作失败
 * 01	操作成功
 * 02	用户名不存在
 * 03   用户名存在    
 * 04	密码错误
 * 05	请求协议参数不完整    
 * 06   用户名或密码错误
*/

@Controller
@RequestMapping(value="/appSK")
public class AppSKController extends BaseController {
	
	@Resource(name="productionService")
	private ProductionService productionService;
	
	@Resource(name="bannerService")
	private BannerService bannerService;
	
	/**
	 * 获取推荐数据
	 */
	@RequestMapping(value="/getRecommendData")
	@ResponseBody
	public Object getRecommendData(Page page){
		List<PageData> varList = new ArrayList<PageData>();
		List<Map<Object,Object>> list = new ArrayList<Map<Object,Object>>();
		Map<Object,Object> _temp = new HashMap<Object,Object>();
		Map<Object,Object> map = new HashMap<Object,Object>();
		logBefore(logger, "获取推荐数据");
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			varList = productionService.list(page);	//列出production列表
			for(int i = 0; i < varList.size(); i++){
				_temp = new HashMap<Object,Object>();
				_temp.put("UNMBER", varList.get(i).get("UNMBER"));
				_temp.put("TITLE", varList.get(i).get("TITLE"));
				_temp.put("USERNAME", varList.get(i).get("USERNAME"));
				_temp.put("COVERY", varList.get(i).get("COVERY"));
				list.add(_temp);
			}
		} catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", "01");
			map.put("data", list);
			logAfter(logger);
		}
		return AppUtil.returnObject(pd, map);
	}
	
	/**
	 * 获取直播Banner数据
	 */
	@RequestMapping(value="/getLeftBannerData")
	@ResponseBody
	public Object getLeftBannerData(Page page){
		List<PageData> varList = new ArrayList<PageData>();
		Map<Object,Object> map = new HashMap<Object,Object>();
		logBefore(logger, "获取直播banner数据");
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			varList = bannerService.list(page);	//列出production列表
		} catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", "01");
			map.put("data", varList);
			logAfter(logger);
		}
		return AppUtil.returnObject(pd, map);
	}
	
	/**
	 * 获取热门数据
	 */
	@RequestMapping(value="/getHotData")
	@ResponseBody
	public Object getHotData(Page page){
		List<PageData> varList = new ArrayList<PageData>();
		Map<Object,Object> map = new HashMap<Object,Object>();
		logBefore(logger, "获取热门数据");
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			varList = productionService.list(page);	//列出production列表
		} catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", "01");
			map.put("data", varList);
			logAfter(logger);
		}
		return AppUtil.returnObject(pd, map);
	}
	
	/**
	 * 获取预告数据
	 */
	@RequestMapping(value="/getPreviewData")
	@ResponseBody
	public Object getPreviewData(Page page){
		List<PageData> varList = new ArrayList<PageData>();
		Map<Object,Object> map = new HashMap<Object,Object>();
		logBefore(logger, "获取预告数据");
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			varList = productionService.list(page);	//列出production列表
		} catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", "01");
			map.put("data", varList);
			logAfter(logger);
		}
		return AppUtil.returnObject(pd, map);
	}
	
	
	/**
	 * 获取频道数据
	 */
	@RequestMapping(value="/getChannelData")
	@ResponseBody
	public Object getChannelData(Page page){
		List<PageData> varList = new ArrayList<PageData>();
		Map<Object,Object> map = new HashMap<Object,Object>();
		logBefore(logger, "获取频道数据");
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			varList = productionService.list(page);	//列出production列表
		} catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", "01");
			map.put("data", varList);
			logAfter(logger);
		}
		return AppUtil.returnObject(pd, map);
	}
}
